package com.ld.admin.util.daliySentence.impl;

import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.ld.admin.util.daliySentence.DaliySentence;
import com.ld.shieldsb.common.core.util.JsoupUtil;

/**
 * 
 * 欧路词典
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年1月8日 上午11:00:38
 *
 */
public class DaliySentenceEudic implements DaliySentence {
    public static final String URL = "http://dict.eudic.net/home/dailysentence";

    @Override
    public String getSentence() {
        String content = null;

        Document document = JsoupUtil.getRemoteURLDocument(URL, null);
        if (document != null) {
            Elements containerEle = document.select("div.containter");
            if (containerEle != null) {
                Elements image = containerEle.select("#showerimg"); // 图片
                if (image != null) {
                    content = "<img src=\"" + image.attr("src") + "\" width='270' >" + "<br/>"; // height='180'
                }
                content += containerEle.select(".sect_en").text() + "<br/>";
                content += containerEle.select(".sect-trans").text() + "";
                content += "【来自<a href='http://dict.eudic.net/home/dailysentence' target='_blank'>「欧路词典」</a>】";
            }
        }
        return content;
    }

}
